<% import static scriptlerweb.RenderUtil.shortenTo %>
<% import static scriptlerweb.RenderUtil.fallback %>
<% import static scriptlerweb.RenderUtil.removeHtml %>
<table border="1" id="scripts">
	<tbody>
		<% def order = request.getAttribute('order') 
		   if(order != null) { %>
		<tr>
			<th>&nbsp;</th>
			<th><a href='/catalog/list/${order}name'>name</a></th>
			<th><a href='/catalog/list/${order}ratingPos'>pos</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/catalog/list/${order}ratingNeg'>neg</a></th>
			<th><a href='/catalog/list/${order}downloadCount'>downloads</a></th>
			<th><a href='/catalog/list/${order}lastUpdate'>last update</a></th>
			<th><a href='/catalog/list/${order}providerId'>provider</a></th>
		</tr>
		<% } else { %>
		<tr>
			<th>&nbsp;</th>
			<th>name</th>
			<th>rating</th>
			<th>downloads</th>
			<th>last update</th>
			<!-- <th>provider</th> -->
		</tr>
		<% } %>
		<% 	def scripts = request.getAttribute('scripts')
			scripts.each{ s -> %>
		<tr class="alt">
			<td><a href='/script/download/${s.id}'><img src="/images/16x16/save.gif" title="download '${s.name}'" alt="download '${s.name}'" /></a>  <a href='/sec/script/edit/${s.id}'><img src="/images/16x16/document_edit.gif" title="edit '${s.name}'" alt="edit '${s.name}'" /></a></td>
			<td><a href='/script/show/${s.id}'>${s.name}</a></td>
			<td>${s.ratingPos} <img class="rate" src="/images/16x16/health-80plus.gif" onclick="rate(${s.id}, 'pos')" title="click to rate - positive ratings: ${s.ratingPos}" alt="click to rate - positive ratings: ${s.ratingPos}" />  ${s.ratingNeg} <img class="rate" src="/images/16x16/health-00to19.gif" onclick="rate(${s.id}, 'neg')" title="click to rate - negative ratings: ${s.ratingNeg}" alt="click to rate - negative ratings: ${s.ratingNeg}" /></td>
			<td>${s.downloadCount}</td>
			<td><%= fallback('', s.lastUpdate.toString()) %></td>
			<%  def colspan = 5
				if(s.providerName) {
					colspan = 6 
					%>
					<td><a href='/provider/show/${s.providerId}'><%= fallback('provider', s.providerName) %></a></td>
			<%  } %>
		</tr>
		<tr>
			<td colspan="<%= colspan %>"><%= shortenTo(150, removeHtml(s.comment))  %></td>
		</tr>
		<% } %>
	</tbody>
</table>